# # -*- coding: utf-8 -*-
# import scrapy
# from spiders.items import IqiyiItem
# from scrapy.selector import Selector
# from scrapy.spiders import CrawlSpider, Rule
# from scrapy.linkextractors.sgml import SgmlLinkExtractor
#
#
# class IqiyiSpider(CrawlSpider):
#     # 爬虫名称
#     name = "iqiyi"
#     # 设置允许的域名
#     allowed_domains = ["list.iqiyi.com"]
#     # 减慢爬取速度为1s
#     # download_delay=1
#     # 设置开始爬去的页面
#     start_urls = ["http://list.iqiyi.com/www/2/-------------11-1-1-iqiyi--.html"]
#     # 自定义配置 pipeline
#     custom_settings = {
#         'ITEM_PIPELINES': {
#             'spiders.pipelines.IqiyiPipeline.IqiyiPipeline': 1,
#         }
#     }
#     # 定义规则
#     rules = [
#         # 电视剧
#         Rule(SgmlLinkExtractor(allow=('http://list.iqiyi.com/www/2/-----------.*--4-\d+-1-iqiyi--.html')),
#              callback="parse_item", follow=True)
#     ]
#
#     def parse_item(self, response):
#         sel = Selector(response)
#         item = IqiyiItem()
#         # 影片名称
#         item['name'] = sel.xpath('//p[@class="site-piclist_info_title"]/a/text()').extract()
#         # item['name']=[n.encode('utf8') for n in name]
#         # 影片类型
#         item['classification'] = sel.xpath(
#             '/html/body/div[4]/div/div/div[1]/div[1]/ul/li[@class="selected"]/a/text()').extract()
#         # albumid
#         item['albumid'] = sel.xpath('//a/@data-qidanadd-albumid').extract()
#         # tvid
#         item['tvid'] = sel.xpath('//a/@data-qidanadd-tvid').extract()
#         return item
